import {
  createRouter,
  createWebHashHistory,
} from 'vue-router';

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login/index')
  },
  {
    path: "/",
    name: "Layout",
    component: () => import("../layout"),
    redirect: "/cashier",
    meta: {
      title: "Layout",
      requiresAuth: true,
    },
    children: [
      {
        path: '/cashier',
        name: 'cashier',
        meta: {
          title: "cashier", // 名称
          // auth: ["admin", "user"], // 权限
          requiresAuth: true,
          // noHidden: true,  // 是否隐藏
        },
        component: () => import('../views/HomeView')
      },
      {
        path: '/commodity',
        name: 'commodity',
        component: () => import('../views/commodity/index')
      },
      {
        path: '/order',
        name: 'order',
        component: () => import('../views/order/index')
      },
      {
        path: '/printd',
        name: 'printd',
        component: () => import('../views/printd/index')
      },
      {
        path: '/member',
        name: 'member',
        component: () => import('../views/member/index')
      },
      {
        path: '/shift',
        name: 'shift',
        component: () => import('../views/shift/index')
      },
      {
        path: '/report',
        name: 'report',
        component: () => import('../views/report/index')
      },
      {
        path: '/setting',
        name: 'setting',
        component: () => import('../views/setting/index')
      },
    ]
  },
  {
    path: "/404NotFound",
    name: "NotFound",
    component: () => import("@/views/error/404NotFound.vue"),
  },
  // { path: "/:pathMatch(.*)*", redirect: "/404NotFound" },
]

// const router = createRouter({
//   history: createWebHistory(process.env.BASE_URL),
//   routes
// })

const router = createRouter({
  history: createWebHashHistory(),
  mode: "history",
  routes,
});

export default router
